package jee.boot.entity.auth;

import com.google.common.collect.Lists;
import jee.boot.common.annotation.Column;
import jee.boot.common.annotation.Table;
import jee.boot.common.annotation.Transient;
import jee.boot.common.basic.interceptor.impl.DefaultPreInsertInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreQueryInterceptor;
import jee.boot.common.basic.interceptor.impl.DefaultPreUpdateInterceptor;
import jee.boot.entity.system.BasicObj;

import java.util.List;

/**
 * 模型
 */
@Table(name = "mt_model")
public class ModelData extends BasicObj<ModelData> {

    private static final long serialVersionUID = 1L;
    /**
     * 模型类型 字典:model_category
     * 规则模型:model_category_1: 用于配置常规项目的数据权限规则,
     * 数据模型:model_category_2: 用于bi项目的Entity定义
     *
     */
    @Column(name = "st_category")
    private String category;
    /**
     * 表名
     */
    @Column(name = "st_table_name")
    private String modelTableName;//表名
    /**
     * 表别名
     */
    @Column(name = "st_table_alias")
    private String tableAlias="a";//表别名
    /**
     * 模型组
     */
    @Column(name = "st_model_group")
    private String modelGroup;//字典：DIC_MT_ModelGroup
    /**
     * 模型状态
     */
    @Column(name = "st_model_status")
    private String modelStatus;//字典：
    /**
     * 超类ID
     */
    @Column(name = "st_super_id",data = {"superModelData.id","superModelData.no","superModelData.code","superModelData.name","superModelData.desc","superModelData.type"})
    private ModelData superModelData;//引用：MT_MODEL
    /**
     * 虚拟标志
     */
    @Column(name = "st_virtual_flag")
    private String virtualFlag;//字典：DIC_SYS_YesNo，用于预定义的不用于业务使用的超类对象

    /**
     * 列
     */
    @Transient
    private List<jee.boot.entity.auth.Column> columnList= Lists.newArrayList();
    /**
     * 行集合
     */
    @Transient
    private List<RowSet> rowSetList=Lists.newArrayList();
    /**
     * 单元格集
     */
    @Transient
    private List<CellSet>cellSetList=Lists.newArrayList();

    /**
     * 列(权限)
     */
    @Transient
    private List<AuthEntity> columnAuthList= Lists.newArrayList();
    /**
     * 行集合(权限)
     */
    @Transient
    private List<AuthEntity> rowSetAuthList=Lists.newArrayList();
    /**
     * 单元格集(权限)
     */
    @Transient
    private List<AuthEntity>cellSetAuthList=Lists.newArrayList();
    public ModelData() {
    }

    public ModelData(String id) {
        super(id);
    }

    public String getModelGroup() {
        return modelGroup;
    }

    public void setModelGroup(String modelGroup) {
        this.modelGroup = modelGroup;
    }

    public String getModelStatus() {
        return modelStatus;
    }

    public void setModelStatus(String modelStatus) {
        this.modelStatus = modelStatus;
    }

    public ModelData getSuperModelData() {
        return superModelData;
    }

    public void setSuperModelData(ModelData superModelData) {
        this.superModelData = superModelData;
    }

    public String getVirtualFlag() {
        return virtualFlag;
    }

    public void setVirtualFlag(String virtualFlag) {
        this.virtualFlag = virtualFlag;
    }

    public List<jee.boot.entity.auth.Column> getColumnList() {
        return columnList;
    }

    public void setColumnList(List<jee.boot.entity.auth.Column> columnList) {
        this.columnList = columnList;
    }

    public List<RowSet> getRowSetList() {
        return rowSetList;
    }

    public void setRowSetList(List<RowSet> rowSetList) {
        this.rowSetList = rowSetList;
    }

    public List<CellSet> getCellSetList() {
        return cellSetList;
    }

    public void setCellSetList(List<CellSet> cellSetList) {
        this.cellSetList = cellSetList;
    }

    public String getTableAlias() {
        return tableAlias;
    }

    public void setTableAlias(String tableAlias) {
        this.tableAlias = tableAlias;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getModelTableName() {
        return modelTableName;
    }

    public void setModelTableName(String modelTableName) {
        this.modelTableName = modelTableName;
    }

    public List<AuthEntity> getColumnAuthList() {
        return columnAuthList;
    }

    public void setColumnAuthList(List<AuthEntity> columnAuthList) {
        this.columnAuthList = columnAuthList;
    }

    public List<AuthEntity> getRowSetAuthList() {
        return rowSetAuthList;
    }

    public void setRowSetAuthList(List<AuthEntity> rowSetAuthList) {
        this.rowSetAuthList = rowSetAuthList;
    }

    public List<AuthEntity> getCellSetAuthList() {
        return cellSetAuthList;
    }

    public void setCellSetAuthList(List<AuthEntity> cellSetAuthList) {
        this.cellSetAuthList = cellSetAuthList;
    }
    @Override
    public void preInsert() {
        new DefaultPreInsertInterceptor().execute(this);
    }
    @Override
    public void preUpdate() {
        new DefaultPreUpdateInterceptor().execute(this);
    }
    @Override
    public void preQuery() {
        new DefaultPreQueryInterceptor().execute(this);
    }
}
